<template>
    <div>
		<img src="https://img01-xusong.91q.com/AE79AD61-2834-4278-A2D9-9B3B6C5A2B06.png" class="logo" />
        <strong class="title">E7社团 后台管理系统</strong>
        <div class="header-avatar">
			<div class="avatar">
				<el-avatar :src="$store.state.sysUser.avatar"></el-avatar>
			</div>
            <el-dropdown>
              <span class="el-dropdown-link">
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
                <el-dropdown-menu slot="dropdown">
                    <!-- <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item> 设置</el-dropdown-item> -->
                    <el-dropdown-item @click.native="login"> 登录</el-dropdown-item>
                    <el-dropdown-item @click.native="logout"> 注销</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
            <!-- <el-link href="http://markerhub.com" target="_blank">网站</el-link>
            <el-link href="http://space.bilibili.com/13491144.com" target="_blank">B站</el-link> -->
        </div>
    </div>
</template>

<script>
export default {
    name: 'modelHeader',
    data() {
        return {
            activeIndex: '1',
            activeIndex2: '1'
        };
    },
    methods: {
        handleSelect(key, keyPath) {
            console.log(key, keyPath);
        },
        logout() {
            let token = localStorage.getItem("token");
            if (token) {
                this.$confirm('确认注销吗?', '提示', {}).then(() => {
                    localStorage.removeItem('token');
                    localStorage.removeItem('user');
                    sessionStorage.removeItem('user');
                    this.$router.push({name: 'Login'});
                    this.$message({
                        message: '已成功注销',
                        type: 'success'
                    })
                }).catch(() => {
                })
            } else {
                this.$confirm('您未登陆', '提示', {})
            }
        },
        login() {
            let token = localStorage.getItem("token"); //拿到token
            if (token) {
                this.$confirm('请勿重复登陆', '提示', {})
            } else {
                this.$router.push({name: 'Login'});
            }
        }
    }
}
</script>

<style scoped>
	.logo{
		position: relative;
		left: -15px;
		width: 85px;
		height: 85px;
		float: left;
	}
	.title{
		position: relative;
		left: -15px;
		font-size: 18px;
		float: left;
	}
	.avatar{
		position: relative;
		left: 30px;
		top: 11px;
	}
.header-avatar {
    float: right;
    width: 210px;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.el-dropdown-link {
    cursor: pointer;
}

.header-avatar {
    float: right;
    width: 210px;
    display: flex;
    justify-content: space-around;
    align-items: center;
}
</style>
